<!DOCTYPE html>
<html>
<head>
		<script>
		function sum(){
			//从输入框取值
			var x=document.getElementById("x").value;
			var y=document.getElementById("y").value;
			//将结果放回input中
			document.getElementById("z").value=parseInt(x)+parseInt(y);
		}
	</script>
</head>

<body>
	<style>
		.input{
			width:30px;
			margin: 0 5px
		}
	</style>

	<div class="d" align="center">
		<input class="input" type="text" id="x" value ="1">+
		<input class="input" type="text" id="y" value ="2">=
		<input class="input" type="text" id="z">
		<input type="button" name="q" value="运算" onclick="sum()">
	</div>


</body>
</html>